﻿using System;
using com.yoozoo.gta.Extension.UGUI.ScreenOrientationEx;
using UnityEditor;
using UnityEngine;

namespace com.yoozoo.gta.Extension.UGUI.Editor
{
    [CustomEditor(typeof(ScreenOrientDetector), true)]
    public class ScreenOrientDetectorEditor:UnityEditor.Editor
    {
        
        
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            
            var detector = target as ScreenOrientDetector;
            GUILayout.Label("Listener Count: "+detector.GetListenerCount());
            
            GUILayout.Label("Current Screen Orientation: "+ ScreenOrientManager.GetInstance().CurrentLogicOrientation);
            serializedObject.Update();
            
            //EditorGUILayout.PropertyField(serializedObject.FindProperty("m_CanvasScaler"));
            //EditorGUILayout.PropertyField(serializedObject.FindProperty("lastScreenWidth"));
            //EditorGUILayout.PropertyField(serializedObject.FindProperty("lastScreenHeight"));

            if(GUILayout.Button("Refresh"))
            {
                
                detector.Refresh();
            }
            
            
            if(GUILayout.Button("ForceCleanup"))
            {
                detector.ForceCleanup();
              
            }

            ScreenOrientManager.GetInstance().AutoAdd =
                GUILayout.Toggle(ScreenOrientManager.GetInstance().AutoAdd, "AutoAdd     是否打开prefab时,自动添加【所有】组件的Adapter ");


            ScreenOrientManager.GetInstance().AutoRemove =
                GUILayout.Toggle(ScreenOrientManager.GetInstance().AutoRemove, "AutoRemove    关闭prefab时,自动移除【所有】横竖屏相等Adapter ");
            
            
            ScreenOrientManager.GetInstance().InspectorAutoAddAdapter =
                GUILayout.Toggle(ScreenOrientManager.GetInstance().InspectorAutoAddAdapter, "InspectorAutoAddAdapter  编辑go的组件时自动添加删除Adapter");
            
            
            ScreenOrientManager.GetInstance().InspectorEditMode =
                GUILayout.Toggle(ScreenOrientManager.GetInstance().InspectorEditMode, "InspectorEditMode   非运行模式下Adapter是否可写(Inspector)");
            
            
           
           
        }
    }
}